package com.i2863.shiroDemo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.util.Date;

/**
 * @author cexy
 * @date 2019/07/16 10:42
 * @description: 系统权限表
 */
@TableName("sys_permission")
@Data
@ToString
public class Permission extends Model<Permission> {

    private static final long serialVersionUID = -5918745285424899926L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 是否可用
     */
    private Integer available;
    /**
     * 权限名称
     */
    @TableField("permission_name")
    private String permissionName;
    /**
     * 父权限ID
     */
    @TableField("parent_id")
    private Integer parentId;
    /**
     * 父权限ID列表
     */
    @TableField("parent_ids")
    private String parentIds;
    /**
     * 权限编码
     */
    @TableField("permission_code")
    private String permissionCode;
    /**
     * 资源类型(menu/button)
     */
    @TableField("resource_type")
    private String resourceType;
    /**
     * 资源路径
     */
    private String url;
    /**
     * 修改时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;
    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Permission permission = (Permission) o;

        if (!id.equals(permission.id)) {
            return false;
        }
        return permissionName.equals(permission.permissionName);

    }
}
